package com.sky.course.service;

import com.sky.course.entity.Course;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
@Component//必须添加
public class CourseClientServiceFallbackFactory implements FallbackFactory<CourseClientService> {
    @Override
    public CourseClientService create(Throwable throwable) {
        return new CourseClientService(){

            @Override
            public boolean add(Course course) {
                return false;
            }

            @Override
            public Course get(Integer cid) {
                return new Course().setCId(cid).setCName("该ID："+ cid + "没有对应的信息,Consumer客户端提供的降级信息，刺此刻服务provider已经关闭。")
                        .setDbSource("no this database in mysql");
            }

            @Override
            public List<Course> list() {
                return null;
            }
        };
    }
}
